/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Login;

import connect.DBUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author soul-lyno
 */
public class AddNauAn {
    public static void AddNauAn(String MaMonAn, String TenMonAn, String NguyenLieu, String ThietBi, String QuyTrinh ) throws SQLException{
        DBUtil objDBUtil = new DBUtil();
        Connection conn = objDBUtil.connect();
        String SQL = "insert into MonAn values(?,?,?,?,?)";
        PreparedStatement pstmt = conn.prepareStatement(SQL);
        pstmt.setString(1, MaMonAn);
        pstmt.setString(2, TenMonAn);
        pstmt.setString(3, NguyenLieu);
        pstmt.setString(4, ThietBi);
        pstmt.setString(5, QuyTrinh);
        pstmt.executeUpdate();
        pstmt.close();
        
    }
    public static void DeleteNauAn(String MaMonAn ) throws SQLException{
        DBUtil objDBUtil = new DBUtil();
        Connection conn = objDBUtil.connect();
        String SQL = "DELETE FROM  MonAn WHERE MaMonAn=?";
        PreparedStatement pstmt = conn.prepareStatement(SQL);
        pstmt.setString(1, MaMonAn);
        pstmt.executeUpdate();
        pstmt.close();
    }
    public static void EditNauAn(String MaMonAn, String TenMonAn, String NguyenLieu, String ThietBi, String QuyTrinh ) throws SQLException{
        DBUtil objDBUtil = new DBUtil();
        Connection conn = objDBUtil.connect();
        String SQL = "UPDATE MonAn SET MaMonAn=?, TenMonAn=?, NguyenLieu=?, ThietBi=?, QuyTrinh=?" + " WHERE MaMonAn=?";
        PreparedStatement pstmt = conn.prepareStatement(SQL);
        pstmt.setString(6, MaMonAn);
        pstmt.setString(1, MaMonAn);
        pstmt.setString(2, TenMonAn);
        pstmt.setString(3, NguyenLieu);
        pstmt.setString(4, ThietBi);
        pstmt.setString(5, QuyTrinh);
        pstmt.executeUpdate();
        pstmt.close();
    }
    
}
